using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;

namespace Jaws.Core.Web.Entities.Profiles
{
    /// <summary>
    /// 
    /// </summary>
    [Serializable]
    public class ProfilePropertyCollection : Collection<ProfileProperty>
    {
        /// <summary>
        /// Gets or sets the <see cref="ProfileProperty"/> with the specified key.
        /// </summary>
        /// <value></value>
        public ProfileProperty this[string key]
        {
            get
            {
                foreach (ProfileProperty p in this)
                {
                    if (p.Key.Equals(key))
                    {
                        return p;
                    }
                }
                return null;
            }

            set
            {
                foreach (ProfileProperty p in this)
                {
                    if (p.Key.Equals(key))
                    {
                        p.Value = value.Value;
                        return;
                    }
                }
                throw new KeyNotFoundException();
            }
        }

        /// <summary>
        /// Determines whether the specified key contains key.
        /// </summary>
        /// <param name="key">The key.</param>
        /// <returns>
        /// 	<c>true</c> if the specified key contains key; otherwise, <c>false</c>.
        /// </returns>
        public bool ContainsKey(string key)
        {
            foreach (ProfileProperty p in this)
            {
                if (p.Key.Equals(key))
                {
                    return true;
                }
            }
            return false;
        }

 }
}